package com.googlecode.slm.domain.web;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: liguangjian
 * Date: 11-10-7
 * Time: 下午2:35
 * To change this template use File | Settings | File Templates.
 */
public class TreeNode {

    /**
     *  node id, which is important to load remote data
     */
    private int id;

    /**
     * parent id id, is not must
     */
    private int pid;

    /**
     * node text to show
     */
    private String text;

    /**
     * node state, 'open' or 'closed', default is 'open'. When set to 'closed', the node have children nodes and will load them from remote site
     */
    private String state;

    /**
     * Indicate whether the node is checked selected.
     */
    private boolean checked;

    private TreeNodeAttributes attributes;
    /**
     * an array nodes defines some children nodes
     */
    private List<TreeNode> children = new ArrayList<TreeNode>();
    

    public TreeNode() {
		super();
	}

	public TreeNode(int id, int pid, String text) {
        this.text = text;
        this.pid = pid;
        this.id = id;
    }

    public TreeNode(int id, int pid, String text, String state) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.state = state;
    }

    public TreeNode(int id, int pid, String text, String state, boolean checked) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.state = state;
        this.checked = checked;
    }

    public TreeNode(int id, int pid, String text, String state, boolean checked, TreeNodeAttributes attributes) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.state = state;
        this.checked = checked;
        this.attributes = attributes;
    }

    public void addTreeNode(TreeNode node){
        children.add(node);
    }
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPid() {
        return pid;
    }

    public void setPid(int pid) {
        this.pid = pid;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public TreeNodeAttributes getAttributes() {
        return attributes;
    }

    public void setAttributes(TreeNodeAttributes attributes) {
        this.attributes = attributes;
    }

    public List<TreeNode> getChildren() {
        return children;
    }

    public void setChildren(List<TreeNode> children) {
        this.children = children;
    }
}
